<%

from yahoo.search.web import WebSearch

def _s(val):
    if form.has_key(val):
        return form[val]
    return ''
# end of_

%>

<html>
<head>
    <title>Kontext Search Page</title>
</head>
<body>

    <center>
    <div id="form" style="padding-top:5px;">
    <form action="" method="get">
        <input type="text" name="que" value="<%=_s('que')%>" style="border:1px solid #CCC" size=35>
        <input type="submit" name="search" value="search">
    </form>
    </div>
    </center>
    <table>
    <tr>
        <td style="text-align:center"><img src="kontext/images/yahoo.gif"/></td>
        <td></td>
        <td style="text-align:center"><img src="kontext/images/kontextMiniLogo.png"/></td>
    </tr>

<%
if not _s('que')=='':
    srch = WebSearch("YahooDemo", query=form['que'], results=20)
    data = srch.parse_results()
    if len(data.results)>0:
        for result in data.results:
%>
    <tr >
    <td width="%50" style="border-bottom:1px solid #CCC;vertical-align:top">
    <h3><a href="summarize.py?url=<%=result['Url']%>&q=<%=_s('que')%>"><%= result['Title'] %></a>
    <a href="<%=result['Url']%>">[»»]</a></h3>
    <div style="padding-left:10px;"><%=result['Summary']%></div><br>
    </td>
    <td></td>
    <td style="border-bottom:1px solid #CCC">
    <h3><a href="summarize.py?url=<%=result['Url']%>&q=<%=_s('que')%>"><%= result['Title'] %></a>
    <a href="<%=result['Url']%>">[»»]</a></h3>
        <iframe src="summarize.py?url=<%=result["Url"]%>&q=<%=_s("que")%>&modal=true&options=limit:300,format:plain" 
                width="100%"
                height="80px"
                style="border:none">
        </iframe>
    </td>
    </tr>

<%
    else:
%>

    There is no search result about <b><%=_s('que')%></b>

<%
else:
%>

    You have to give a search criteria..
</table>
</html>
